/**
 * @brief 
 *  copyright .
 */

typedef long unsigned int size_t;
// typedef struct __qb_gsl_block gsl_block;
struct gsl_block_struct {
  size_t size;
  double *data;
};

typedef struct gsl_block_struct gsl_block;

typedef struct {
  size_t size;
  size_t stride;
  double *data;
  gsl_block *block;
  int owner;
} gsl_vector;


double gsl_vector_get(const gsl_vector * v, const size_t i);
void gsl_vector_set(gsl_vector * v, const size_t i, double x);

typedef struct
{
  size_t size1;
  size_t size2;
  size_t tda;
  double * data;
  gsl_block * block;
  int owner;
} gsl_matrix;
int gsl_matrix_get_row(gsl_vector * v, const gsl_matrix * m, const size_t i);
int gsl_matrix_get_col(gsl_vector * v, const gsl_matrix * m, const size_t j);
int gsl_matrix_set_row(gsl_matrix * m, const size_t i, const gsl_vector * v);
int gsl_matrix_set_col(gsl_matrix * m, const size_t j, const gsl_vector * v);
double gsl_matrix_get(const gsl_matrix * m, const size_t i, const size_t j);
void gsl_matrix_set(gsl_matrix * m, const size_t i, const size_t j, const double x);

extern "Python" int fCb(const gsl_vector*x, void*paramsCb, gsl_vector*f);  // 目标差异
extern "Python" int jacCb(const gsl_vector*x, void*paramsCb, gsl_matrix*J);  // 雅可比矩阵

int search_by_nlinear_lms(
    int nObject,  // 分目标数量
    int nVariable,  // 变量数量
    void* paramsCb,  // 回调函数的环境参数对象
    double tol,  // 迭代时，变量的容忍值
    double* vars  // 待优化的变量，初值入，结果回，长度为 nVariable
);
